import java.util.ArrayList;
import java.util.Scanner;


public class Array {
	public static void main(String args[]){
		ArrayList<Dog>doglist=new ArrayList<Dog>();
		
		String in1;
		String in2;
		boolean z=true;
		while(z==true){
			Scanner in=new Scanner(System.in);
			in1=in.nextLine();	
			if (in1.equalsIgnoreCase("Stop")){
				z=false;
			}
			else {
				doglist.add(new Dog(5,in1));
			}
		}
		Scanner scrub=new Scanner(System.in);
		in2=scrub.nextLine();
		for(int p=0; p<doglist.size(); p++){
			Dog x=doglist.get(p);
			if (x.getName().equalsIgnoreCase(in2)){
				doglist.remove(p);
			}
		}
		for(int t=0; t<doglist.size(); t++){
			Dog x=doglist.get(t);
			System.out.println(x.getName());
		}

		}
	}

